package com.sysu.minsysu.xyxw;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.ProgressBar;
import android.widget.VideoView;

import com.sysu.minsysu.R;

public class VideoPlayView extends Activity{

	
//	public void onCreate( Bundle savedInstanceState ){
//		super.onCreate(savedInstanceState);
//		requestWindowFeature( Window.FEATURE_NO_TITLE);
//		getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//		setContentView(R.layout.videoplayer);
//		mVideoView = (VideoView)findViewById(R.id.videoview);
//		
//		Intent intent =getIntent();
//		mURLString = intent.getStringExtra("url");
//		MediaController controller = new MediaController(this);
//		mVideoView.setMediaController(controller);
//		
//		mVideoView.setVideoURI( Uri.parse(mURLString));
//		mVideoView.requestFocus();
//		mVideoView.start();
//	}
	
	VideoView mVideoView;
	String mURLString;
	ImageView mImageView;
	ProgressBar mProgressBar;
	 @Override 
	    protected void onCreate(Bundle savedInstanceState) { 
	        super.onCreate(savedInstanceState); 
			requestWindowFeature( Window.FEATURE_NO_TITLE);
			getWindow().setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
	        this.setContentView(R.layout.videoplayer);

	        mVideoView = (VideoView) this.findViewById(R.id.videoview); 
	        mImageView = (ImageView) this.findViewById(R.id.image); 
	        mImageView.setImageResource(R.drawable.icon); 
	        mProgressBar=(ProgressBar) this.findViewById(R.id.progress);

	        MediaController controller = new MediaController(this); 
	        mVideoView.setMediaController(controller); 
	        mVideoView.setOnPreparedListener(new OnPreparedListener() { 
	            @Override 
	            public void onPrepared(MediaPlayer mp) { 
	                mProgressBar.setVisibility(View.GONE); 
	                mImageView.setVisibility(View.GONE); 
	                mp.start(); 
	            }

	        });

			Intent intent =getIntent();
			mURLString = intent.getStringExtra("url");
	        mVideoView.setVideoURI( Uri.parse(mURLString));
	    
	}
}
